/********************************************************************************
* @author: Liu  HZ
* @date: 2024/9/21
* @description: 
********************************************************************************/

#ifndef THE_PATH_OF_CPP_CODE_H
#define THE_PATH_OF_CPP_CODE_H

#include <iostream>
#include <string>
#include <set>
#include <unordered_set>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <algorithm>

using namespace std;

bool allEven(uint64_t a) {
    return a % 2 == 0;
}

/*
 * 最长子字符串长度
 */
pair<uint64_t, string> maxEvenSubstring(const string &s) {
    uint64_t n = s.size();
    int countO;
    int maxLength = 0;
    int bestStart = 0;

    for (int start = 0; start < n; ++start) {
        countO = 0; // 重置计数器
        for (int i = start; i < start + n; ++i) {
            char c = s[i % n];
            if (c == 'o') countO++;

            // 检查当前子串是否符合条件，且长度是否更优
            if (allEven(countO) && i - start + 1 > maxLength) {
                maxLength = i - start + 1;
                bestStart = start;
            }
        }
    }

    string maxSubstring = s.substr(bestStart, maxLength);

    maxSubstring = maxSubstring + s.substr(0, (bestStart + maxLength) % s.size());

    cout << bestStart << endl;
    return make_pair(maxLength, maxSubstring);
}

#endif //THE_PATH_OF_CPP_CODE_H
